package com.nc.user.model.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * 创建人:    xvzhe
 * 创建时间:
 * 修改时间:
 * 版本:      v1.0
 */
@Data
@Entity
@EntityListeners(AuditingEntityListener.class)
@DynamicInsert
@DynamicUpdate
@ApiModel("用户表")
public class FrmUsers {
    @Id
    @GeneratedValue(generator = "NumberIdProduce")
    @GenericGenerator(name = "NumberIdProduce", strategy = "com.plug.idProduce.NumberIdProduce")
    private String id;

    @Column
    @ApiModelProperty("状态")
    private Boolean status;

    @Column
    @ApiModelProperty("密码")
    private String password;

    @Column(unique = true)
    @ApiModelProperty("手机")
    private String mobile;

    @Column
    @ApiModelProperty("名称")
    private String nickName;

    @Column(columnDefinition = "int default 0")
    @ApiModelProperty("钻石个数")
    private Integer diamond;

    @Column(columnDefinition = "int default 0")
    @ApiModelProperty("金币个数")
    private Integer gold;

    @Column
    @ApiModelProperty("邮箱")
    private String email;

    @Column(precision = 27, scale = 2, columnDefinition = "decimal default 0")
    @ApiModelProperty("消费金额")
    private BigDecimal amount;

    @Column(precision = 27, scale = 2, columnDefinition = "decimal default 0")
    @ApiModelProperty("当前余额")
    private BigDecimal balance;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @CreatedDate
    @Column
    private Date createTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @LastModifiedDate
    @Column
    private Date modifiedTime;

    @ApiModelProperty("会员角色")
    @OneToMany
    private List<FrmRole> frmRoles;
}
